// 自定义触摸指令
export default {
    touchmove: {
        inserted: function (el, binding) {
            const callBack = binding.value;
            if (!callBack) return
            bindEvent(el, callBack)
        }
    }
}

const bindEvent = (el, callback) => {
    let stratClientY;
    el.addEventListener('touchstart', function (e) {
        stratClientY = e.touches[0].clientY;
        stratClientY = Math.ceil(stratClientY);
    })
    el.addEventListener('touchmove',function(e){
        let moveClientY = e.touches[0].clientY;
        moveClientY = Math.ceil(moveClientY);
        let rusultMove = stratClientY - moveClientY;
        
        callback(rusultMove)

        stratClientY = moveClientY
    })
    el.addEventListener('touchend',function(){
        callback(undefined,'touchend')
    })
};